<?php
/**
 * 
 * ClientEngage: ClientEngage Visitor Voice (http://www.clientengage.com)
 * Copyright 2012, ClientEngage (http://www.clientengage.com)
 *
 * You must have purchased a valid license from CodeCanyon in order to have 
 * the permission to use this file.
 * 
 * You may only use this file according to the respective licensing terms 
 * you agreed to when purchasing this item on CodeCanyon.
 * 
 * 
 * 
 *
 * @author          ClientEngage <contact@clientengage.com>
 * @copyright       Copyright 2013, ClientEngage (http://www.clientengage.com)
 * @link            http://www.clientengage.com ClientEngage
 * @since           ClientEngage - Visitor Voice v 1.0
 * 
 */
?>
<div class="visitorvoices view row">
    <div class="actions span2">
        <ul class="nav nav-list">
            <li class="nav-header"><?php echo __('Actions'); ?></li>
            <li><?php echo $this->Html->link(__('Back to Responses'), array('action' => 'responses', $visitorvoice['Visitorvoice']['visitorform_id'])); ?> </li>
        </ul>

        <div class="row-fluid">
            <span>&nbsp;</span>
            <?php echo $this->Form->postLink(__('Delete Visitorvoice'), array('action' => 'delete', $visitorvoice['Visitorvoice']['id']), array('class' => 'btn btn-danger span12'), __('Are you sure you want to delete this response?')); ?>
        </div>
    </div>
    <div class="span10">
        <ul class="pager">
            <?php if (isset($neighbours['next']['Visitorvoice']['id'])): ?>
                <li class="previous">
                    <?php echo $this->Html->link('&laquo;', array('action' => 'view', $first['Visitorvoice']['id']), array('escape' => false)); ?>
                    <?php echo $this->Html->link('&larr; ' . __('newer'), array('action' => 'view', $neighbours['next']['Visitorvoice']['id']), array('escape' => false)); ?>
                </li>
            <?php endif; ?>
            <?php if (isset($neighbours['prev']['Visitorvoice']['id'])): ?>
                <li class="next">
                    <?php echo $this->Html->link('&raquo;', array('action' => 'view', $last['Visitorvoice']['id']), array('escape' => false)); ?>
                    <?php echo $this->Html->link(__('older') . ' &rarr;', array('action' => 'view', $neighbours['prev']['Visitorvoice']['id']), array('escape' => false)); ?>
                </li>
            <?php endif; ?>
        </ul>
        <h2><?php echo __('Visitorvoice'); ?></h2>
        <dl>
            <dt><?php echo __('Visitorform'); ?></dt>
            <dd>
                <?php echo $this->Html->link($visitorvoice['Visitorform']['title'], array('controller' => 'visitorforms', 'action' => 'view', $visitorvoice['Visitorform']['id'])); ?>
                &nbsp;
            </dd>
            <dt><?php echo __('Useragent'); ?></dt>
            <dd>
                <?php echo $this->Layout->renderUserAgent($visitorvoice['Visitorvoice']['useragent']); ?>&nbsp;
            </dd>
            <dt><?php echo __('Referer'); ?></dt>
            <dd>
                <?php echo $this->Html->link($visitorvoice['Visitorvoice']['referer'], $visitorvoice['Visitorvoice']['referer'], array('target' => '_blank')); ?>
                &nbsp;
            </dd>
            <dt><?php echo __('Started'); ?></dt>
            <dd>
                <?php echo $this->Layout->displayTimeDefault($visitorvoice['Visitorvoice']['started']); ?>
                &nbsp;
            </dd>
            <dt><?php echo __('Created'); ?></dt>
            <dd>
                <?php echo $this->Layout->displayTimeDefault($visitorvoice['Visitorvoice']['created']); ?>
                &nbsp;
            </dd>
            <?php
            if (strtotime($visitorvoice['Visitorvoice']['started']) !== false && strtotime($visitorvoice['Visitorvoice']['created']) !== false)
            {
                $diff = strtotime($visitorvoice['Visitorvoice']['created']) - strtotime($visitorvoice['Visitorvoice']['started']);
                $duration = gmdate("H:i:s", $diff);
                ?>
                <dt><?php echo __('Duration'); ?></dt>
                <dd>
                    <?php echo $duration; ?>
                    &nbsp;
                </dd>
            <?php } ?>
        </dl>





        <dl class="single_response">
            <?php foreach ($responses as $response): ?>
                <dt><?php echo $response['Field']['title']; ?></dt>
                <dd>
                    <?php
                    if ($response['Response']['value'] != null)
                        echo $response['Response']['value'];
                    if (!empty($response['Response']['SelectedOption']))
                        echo $response['Response']['SelectedOption']['title'];
                    if (!empty($response['Response']['FieldOption']))
                    {
                        echo '<ul>';
                        foreach ($response['Response']['FieldOption'] as $opt)
                        {
                            echo '<li>' . $opt['title'] . '</li>';
                        }
                        echo '</ul>';
                    }
                    ?>
                </dd>
            <?php endforeach; ?>
        </dl>

        <ul class="pager">
            <?php if (isset($neighbours['next']['Visitorvoice']['id'])): ?>
                <li class="previous">
                    <?php echo $this->Html->link('&laquo;', array('action' => 'view', $first['Visitorvoice']['id']), array('escape' => false)); ?>
                    <?php echo $this->Html->link('&larr; ' . __('newer'), array('action' => 'view', $neighbours['next']['Visitorvoice']['id']), array('escape' => false)); ?>
                </li>
            <?php endif; ?>
            <?php if (isset($neighbours['prev']['Visitorvoice']['id'])): ?>
                <li class="next">
                    <?php echo $this->Html->link('&raquo;', array('action' => 'view', $last['Visitorvoice']['id']), array('escape' => false)); ?>
                    <?php echo $this->Html->link(__('older') . ' &rarr;', array('action' => 'view', $neighbours['prev']['Visitorvoice']['id']), array('escape' => false)); ?>
                </li>
            <?php endif; ?>
        </ul>
    </div>
</div>